package com.ruoyi.robot.config;

import com.ruoyi.robot.Interceptor.JWTInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @author admin
 */
@Configuration
public class IntercaptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JWTInterceptor())
                //拦截的路径
                .addPathPatterns("/robot/**")
//                .excludePathPatterns("/robot/customer/**","/robot/api/wx-pay/**","/robot/essay/**")
                .excludePathPatterns("/robot/customer/**","/robot/essay/**")
                .excludePathPatterns("/robot/robot/**","/robot/robotType/**","/robot/orderInfo/**")
                .excludePathPatterns("/img/**")
                .excludePathPatterns("/robotImg/**")
                .excludePathPatterns("/robot/api/wx-pay/native/notify")
                .excludePathPatterns("/robot/api/wx-pay/refunds/notify")
                .excludePathPatterns("/robot/customer/login");


                //排除登录接口
//                .excludePathPatterns("/customer/**")
//                .excludePathPatterns("/dev-api/**")
//                .excludePathPatterns("/monitor/**","/system/**","/tool/**")
//                .excludePathPatterns("/login", "/register", "/captchaImage")
//                .excludePathPatterns("/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**")
//                .excludePathPatterns("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**");
////                .excludePathPatterns("/api/wx-pay/**");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //   访问相对路径
//        registry.addResourceHandler("/song/**").addResourceLocations("classpath:/song/");
        //访问绝对路径 访问路径和 存放路径可以自定义，建议存放路径放到配置文件中
        registry.addResourceHandler("/song/**").addResourceLocations("file:D:/hulianwangjia/music/");
        registry.addResourceHandler("/img/**").addResourceLocations("file:D:/hulianwangjia/picture/");
        registry.addResourceHandler("/robotImg/**").addResourceLocations("file:D:/hulianwangjia/robotImg/");
    }
}

